﻿using JDKD.BMCS.Instruction;
using NutShell.DesignPattern;

namespace JDKD.BMCS.Business
{
        public class ShiftOperation : Operation
        {
                public ShiftOperation(int id, bool modify)
                        : base("Raise", id, modify)
                {
                }

                public override void Run()
                {
                        BusinessCache cache = Singleton<BusinessCache>.Instance;
                        Channel channel = cache.Channels[Id];

                        if (Modify)
                        {
                                //翻钢启动
                                channel.ShiftState = ShiftState.已翻;
                                

                                if (Modify)
                                {
                                        //挡板复位
                                        new RaiseOperation(Id, !Modify).Run();
                                }
                        }
                        else
                        {
                                channel.ShiftState = ShiftState.未翻;
                        }
                        SerialPortCommunication.SendShiftInstruction(Id, Modify);
                }
        }
}